import java.awt.*;


public class Segment {
	static final int UP=0,DOWN=1,LEFT=2,RIGHT=3;
	private boolean isHorizontal;
	private int currentDirection;
	private int xPos,yPos;
	
	public Segment(int currentDirection, int xPos, int yPos){
		this.currentDirection=currentDirection;
		if (currentDirection<2)
			isHorizontal=true;
		else
			isHorizontal=false;
		
		this.xPos=xPos;
		this.yPos=yPos;
		
	}
	
	
	public void move(){
		switch(currentDirection){
		case Segment.UP:
			yPos-=1;
			break;
		case Segment.DOWN:
			yPos+=1;
			break;
		case Segment.LEFT:
			xPos-=1;
			break;
		case Segment.RIGHT:
			xPos+=1;
		}
	}
	/*
	 * possibly unnecessary // Nahhhh
	 */
	public void changeDirection(Segment s){
		this.currentDirection=s.getDirection();
		this.isHorizontal=s.isHorizontal();
	}
	
	public void changeDirection(int direction){	
		this.currentDirection=direction;
		if (currentDirection==Segment.LEFT||currentDirection==Segment.RIGHT)
			isHorizontal=true;
		else
			isHorizontal=false;
	}
	
	
	//Getters and Setters
	public int getXPos(){
		return xPos;
	}
	public int getYPos(){
		return yPos;
	}
	
	public int getDirection(){
		return this.currentDirection;
	}
	
	public boolean isHorizontal(){
		return this.isHorizontal;
	}
	
	public Point getPoint(){
		return new Point(xPos,yPos);
	}
	
	
	public void draw(Graphics g, Dimension d){
		g.fill3DRect(xPos*d.width,yPos*d.height,d.width-1,d.height-1,false);
		
	}
	
}
